package pl.enigmatic.parser.string.java.awt;

import java.awt.Insets;

import pl.enigmatic.parser.string.ArrayConverter;
import pl.enigmatic.parser.string.Converter;


public class InsetsConverter extends Converter<Insets> {

	private final ArrayConverter<Integer> array = new ArrayConverter<Integer>(Integer[].class);

	@Override
	public Insets convert(final String value) {
		final Integer[] coords = array.convert(value);
		return new Insets(coords[0], coords[1], coords[2], coords[3]);
	}

	@Override
	public String convertBack(final Insets value) {
		return array.convertBack(new Integer[] { value.top, value.left, value.bottom, value.right });
	}
}
